//
// Created by user on 2022/3/9.
//
#include <vector>
#include <sstream>
using namespace std;
string longestCommonPrefix(vector<string>& strs) {
    if (strs.size() == 0) return "";

    int rows = strs.size();
    int cols = strs[0].length();
    for (int i = 0; i < cols; i++) {
        char firstChar = strs[0][i];
        for (int j = 1; j < rows; j++) {
            if (strs[j].length() == i || strs[j][i] != firstChar) {
                return strs[0].substr(0, i);
            }
        }
    }
    return strs[0];

}